#include<stdio.h>
#include<stdlib.h>


int maxProfit(int* prices, int pricesSize) {
    int i = 0;
    int minnum = INT_MAX;
    int maxnum = 0;
    for (i = 0; i < pricesSize; i++) {
        minnum = min(minnum, prices[i]);
        maxnum = max(maxnum, prices[i] - minnum);
    }
    return maxnum;
}